class Solution {
public:
    vector<int> twoSum(vector<int>& price, int target) 
    {
        int n=price.size();
        int left=0;int right=n-1;
        vector<int>ans;
        while(left<right)
        {
            if(price[left]+price[right]>target)
            right--;
            else if(price[left]+price[right]<target)
            left++;
            else
            {
                ans.push_back(price[left]);
                ans.push_back(price[right]);
                return ans;
            }
        }return ans;
    }
};
